package com.z6school.manage.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.z6school.manage.po.UserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserRolesMapper extends BaseMapper<UserRole> {

    @Delete("delete from user_role where roleId=#{roleId}")
    int deleteObjectByRoleId(@Param("roleId") Integer roleId);

    @Delete("delete from user_role where userId=#{userId}")
    int deleteObjectByUserId(@Param("userId") Integer userId);

    int insertObjects(
            @Param("userId")Integer userId,
            @Param("roleIds")Integer[] roleIds);

    /**基于用户id查询角色id信息*/
    @Select("select roleId from user_role where userId=#{id}")
    List<Integer> findRoleIdsByUserId(Integer id);

}
